<link type="text/css" href="/admins/js/pagerView/pager-view.css" rel="stylesheet" />
<link type="text/css" href="/admins/js/jquery/css/ui-lightness/jquery-ui-1.8.20.custom.css" rel="stylesheet" />
<script type="text/javascript" src="/admins/js/jquery/jquery-ui-1.8.20.custom.min.js"></script>
<script type="text/javascript" src="/admins/js/jquery/jquery.ui.datepicker-zh-CN.js"></script>
<script type="text/javascript" src="/admins/js/pagerView/pager-view.js"></script>
<script type="text/javascript">
    $(function(){
        $.datepicker.setDefaults( $.datepicker.regional[ "zh-CN" ] );
        $( "#form1 #sel #starttime" ).datepicker({
            changeMonth: true,
            changeYear: true
        });
        $( "#form1 #sel #endtime" ).datepicker({
            changeMonth: true,
            changeYear: true
        });
        $(".lixiala").click(function(){
            $(".lixiala").attr("class","lixiala");
            $(".lixiala").next("div").hide();

            $(this).attr("class","lixiala bton");
            $(this).next("div").show();
        });
        $('.countryzm a').each(function(index,item){
            $(item).click(function(){
                $('.countryzm li.zmon').removeClass('zmon');
                $(this).parent().addClass('zmon');
                $('#countryTab ul').hide();
                $('#countryTab ul').eq(index).show();
                return false;
            });
        });
        $('.countrylist a').bind('click',function(){
             $("#form1 #cityid").val($(this).attr('cid'));
             var name = $(this).text();
             $(".lixiala span").text(name);
             $("#form1 #cityname").val(name);
             $(".guojiaceng").hide();
             $(".lixiala").removeClass("bton");
         });
    });
</script>

<form action="/admini/manageuser/index/"  method="get"  id="form1">
    <div style=" border:1px solid #DDDDDD; padding:2px 0 0 20px; margin:2px;line-height: 36px;" id='sel'> 
        <div style="float: left;margin-right: 10px;">
        <label for="quick">快速搜索：</label><input type="text" id="quick" name="quick" value="<?php echo $this->quick; ?>" />
        <select id="dateselect" name="dateselect">
            <option value="regedit" <?php if ($this->dateselect == 'regedit') { echo "selected";}?>>注册时间</option>
            <option value="login" <?php if ($this->dateselect == 'login') { echo "selected"; } ?>>登录时间</option>
        </select>
        <label for="starttime">：</label><input type="text" id="starttime" name="starttime" value="<?php echo $this->starttime; ?>" />
        <label for="endtime">-- </label><input type="text" id="endtime" name="endtime" value="<?php echo $this->endtime; ?>"  />
        </div>
        <div class="biaoxiala">
            <div class="lixiala">
                <span><?php echo $this->cityname?$this->cityname:"全部国家";?></span>
            </div>
            <div class="guojiaceng" style="display:none;left: 643px;">
                <div class="remen">
                        <h2>热门国家和地区</h2>
                    <ul class="countrylist">
                        <li><a href="javascript:void(0)" id="c_us" cid="0">全部国家</a></li>
                        <li><a href="javascript:void(0)" cid="1">美国</a></li>
                        <li><a href="javascript:void(0)" cid="2">加拿大</a></li>
                        <li><a href="javascript:void(0)" cid="3">澳大利亚</a></li>
                        <li><a href="javascript:void(0)" cid="47">日本</a></li>
                        <li><a href="javascript:void(0)" cid="39">台湾</a></li>
                        <li><a href="javascript:void(0)" cid="4">新西兰</a></li>
                        <li><a href="javascript:void(0)" cid="5">英国</a></li>
                        <li><a href="javascript:void(0)" cid="42">马来西亚</a></li>
                    </ul>
                </div>
                <div class="allcountry">
                    <h2>全部国家和地区</h2>
                    <ul class="countryzm">
                        <?php foreach ($this->words as $char){ ?>
                            <li <?= $char=='A'?'class="zmon"':'' ?>><a href="javascript:void(0)"><?= $char ?></a></li>
                        <?php } ?>
                    </ul>
                    <div id="countryTab">
                        <?php foreach ($this->words as $char){ ?>
                        <ul class="countrylist"  <?= $char=='A'?'':'style="display:none"' ?>>
                           <?php $citys= Application_Model_city::GetBySortCode($char);
                                foreach ($citys as $city){
                           ?>
                            <li><a href="javascript:void(0)" cid="<?= $city->Id ?>"><?= $city->Name ?></a></li>
                            <?php } ?>
                        </ul>
                        <?php } ?>
                    </div>
                </div>
            </div>
        </div>
        <input type="hidden" name="cityid" id="cityid" value="<?php echo $this->cityid?$this->cityid:"";?>"/>
        <input type="hidden" name="cityname" id="cityname" value="<?php echo $this->cityname?$this->cityname:"全部国家";?>"/>
        <input type="hidden" name="orderby" id="orderby" value="<?php echo $this->orderby?$this->orderby:""; ?>" />
        <input type="hidden" name="operate" id="operate" value="selectuser" />
        <input type="submit" id="queryButton" name="queryButton" value="查询"/>
    </div>
</form>

<div class="dataTable" style="clear: both;">
    <table>         
    <tfoot>
      <tr><td colspan="14"><input class="button" id="exit-button" type="button" value="编辑" /></td></tr>
    </tfoot>
        <tr>
            <th class="w1" width="5px"></th>
            <th class="w2" width="5%" nowrap>ID</th>
            <th class="w3" width="12%" nowrap>用户名</th>
            <th class="w4" width="12%" nowrap>email</th>
            <th class="w16" width="12%" nowrap>区号+手机号</th>
            <th class="w5" width="12%" nowrap>注册时间</th>
            <th class="w6" width="12%" nowrap>最后登录时间</th>
            <th class="w7" width="5%" nowrap>用户类型</th>
            <th class="w8" width="5%" nowrap>仓库地址</th>
            <th class="w9" width="5%" nowrap>成长值</th>
            <th class="w10" width="5%" nowrap>余额</th>
            <th class="w13" width="5%" nowrap>登录次数</th>
            <th class="w11" width="10%" nowrap>最后登录IP</th>
            <th class="w12" width="10%"nowrap><a href="javascript:void(0)" class="indexa orderby" style="color: #fff;">最后登录国家</a></th>
        </tr>  

        <?php
		//var_dump($this->useralllist);exit;
        if ($this->useralllist) {
            foreach ($this->useralllist as $Item) {
					?>
                <tr>
                    <td class="w1" width="5px"><input type="checkbox" value="<?php echo $Item->id; ?>" class="checkbox-del" name='checkbox'  /></td>
                    <td class="w2"><?php echo $Item->id; ?></td>
                    <td class="w3"><a href="/admini/manageuser/userdetail/id/<?php echo $Item->id;?>" class="indexa"><?php echo !empty(htmlspecialchars($Item->nikename))?htmlspecialchars($Item->nikename):"昵称为空"; ?></a></td>
                    <td class="w4"><?php echo htmlspecialchars($Item->email); ?></td>
                    <td class="w16"><?php echo $Item->phone; ?></td>
                    <td class="w5"><?php echo $Item->datecreated; ?></td>
                    <td class="w6"><?php echo $Item->lastLogin; ?></td>
                    <td class="w7"><?php echo $Item->userType; ?></td>
                    <td class="w8"><?php echo $Item->storeno; ?></td>
                    <td class="w9"><?php echo $Item->Account->score!=''?$Item->Account->score:0;?></td>
                    <td class="w10"><?php echo $Item->Account->money!=''?$Item->Account->money:0;?></td>
                    <td class="w12"><?php echo $Item->logintimes; ?></td>
                    <td class="w11"><?php echo $Item->loginip; ?></td>
                    <td class="w12"><?php echo $Item->cityname?$Item->cityname->Name:$Item->byip; ?></td>
                </tr>
        <?php
    }
}
?>
    </table>
</div>
<div class="toolbar">
    
    <?php //echo $this->partial('paging.phtml', array("pages" => $this->userall,"pamas"=>"username=".$this->nikename."&email=$this->email&storeno=$this->storeno&dateselect=$this->dateselect&starttime=$this->starttime&endtime=$this->endtime")); ?>
    <?php echo $this->partial('paging.phtml', array("pages" => $this->userall,"pamas"=>"quick=".$this->quick."&dateselect=$this->dateselect&starttime=$this->starttime&endtime=$this->endtime&cityid=$this->cityid&cityname=$this->cityname&orderby=$this->orderby")); ?>
</div>
<?php
if(isset($this->message) && $this->message!=""){
    echo '<script language="javascript" type="text/javascript">alert("'. $this->message .'")</script>';
}

?>
<script language="javascript">
    $(".orderby").click(function(){
        var order = $("#orderby").val();
        if(order == "" || order == "asc"){
            $("#orderby").val("desc");
        } else if(order == "desc") {
            $("#orderby").val("asc");
        }
        $("#form1").submit();
    });
    $('#exit-button').click(function(){
        var id = getbillid();
        if(id == ''){
            alert("请选择用户");
            return false;
        }else{
           location.href='/admini/manageuser/edit/id/'+id;
        }
    });
    function getbillid()
    {
         var id = '';
         $('input[name="checkbox"]:checked').each(function(){    
		id = $(this).val();
                return false;
	});
        return id;
    }
	
</script>
